package PaperManagerGUI;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class DrawGraph extends JPanel {
	/**
	 * 
	 */
	//private static final long serialVersionUID = 1L;
	int N;
	private Point[] Info;
	private boolean[][] Relation;
	
	//private int[] RealNum1;
	//private int[] RealNum2;
	public DrawGraph(int n,Point[] info,boolean[][] relation){
		this.N = n;
		this.Info = new Point[n];
		
		this.Relation = new boolean[n][n];
		
		for(int i = 0; i < n; i++){
			this.Info[i] = info[i];
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				this.Relation[i][j] = relation[i][j];
			}
		}
		
	}
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
		for (int i = 0; i < N; i++) {
			g.setColor(Color.BLACK);
			g.drawString(Info[i].Name, Info[i].X,Info[i].Y);
			g.setColor(Color.YELLOW);
			// g.fillOval(row,col,30,30);
			switch(Info[i].Type){
				case 0: g.fillRect(Info[i].X,Info[i].Y, GraphConstDefine.NodeWidth, GraphConstDefine.NodeHegiht); break;
				case 1: g.fillArc(Info[i].X, Info[i].Y, GraphConstDefine.NodeWidth, GraphConstDefine.NodeHegiht, 0, 360); break;
			};
			
			// g.fillOval(6*x/5,8*y/5,3*x/5,3*y/5);
			
			for(int j = 0; j < N; j++){
				if(this.Relation[j][i]){
					g.drawLine(Info[i].X + GraphConstDefine.NodeWidth/2,Info[i].Y + GraphConstDefine.NodeHegiht/2, 
							Info[j].X + GraphConstDefine.NodeWidth/2,Info[j].Y + GraphConstDefine.NodeHegiht/2);
				}
			}
		}
	}

}
